import { Context, Inject, Provide } from '@midwayjs/core'
import { IUserOptions } from '../interface'
import { InjectEntityModel } from '@midwayjs/typeorm'
import { Repository } from 'typeorm'
import { UserEntity } from '@/entity/user.entity'

@Provide()
export class UserService {
  @InjectEntityModel(UserEntity)
  entity: Repository<UserEntity>

  @Inject()
  ctx: Context

  async findAll() {
    const list = await this.entity.find()

    return list
  }

  async getUser(options: IUserOptions) {
    return {
      uid: options.uid,
      username: 'mockedName',
      phone: '12345678901',
      email: 'xxx.xxx@xxx.com',
    }
  }
}
